home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / hexa.lha / hexa / endian.c < prev    next >
Text File  |  1992-08-18  |  431b  |  14 lines

  1. main ()
  2. {
  3.    union { int i; char a [4] } u;
  4.  
  5.    u.i = 0x0815;
  6.    if (u.a [0] == 21 && u.a [1] == 8 && u.a [2] == 0 && u.a [3] == 0)
  7.       (void) printf ("this machine is little-endian\n");
  8.    else if (u.a [0] == 0 && u.a [1] == 0 && u.a [2] == 8 && u.a [3] == 21)
  9.       (void) printf ("this machine is big-endian\n");
  10.    else
  11.       (void) printf ("cannot determine whether this machine is little- or big-endian\n");
  12.    return 0;
  13. }
  14.